# -*- coding: utf-8 -*-

<%page cached="True" cache_type="memory" cache_key="${c.cache_key}"/>
## TODO: invalidate the cache for the given keys when necessary.

<%inherit file="../base.mako"/>

<%namespace name="student_comps" file="/students/components.mako"/>
<%namespace name="machine_comps" file="/machines/components.mako"/>

<%def name="javascript()">
    ${parent.javascript()}
    ${self.javascript_link('jquery', 'jquery.quicksearch.js')}
</%def>

<%def name="css()">
	${parent.css()}
	${self.css_link('table')}
</%def>

<%def name="dom_onLoad()">
	${parent.dom_onLoad()}
	$('table#table_machines tbody tr').quicksearch({
		position: 'before',
		attached: 'table#table_machines',
		stripeRowClass: ['odd', 'even'],
		labelText: 'Filter: ',
		loaderImg: '/img/busy.gif',
		delay: 25,
		focusOnLoad: true,
	});
</%def>
     
<h1>
Machines
</h1>

<table id="table_machines">
	<thead>
	<tr>
		<th>Hostname</th>
		<th> IP </th>
		<th>Mac address</th>
		<th>Student</th>
	</tr>
	</thead>
%for machine in c.machines_q.all():
	<tr>
	  	<td>
	    	${machine_comps.link_to(machine, 'hostname')}
		</td>
		<td>
	    	${machine_comps.link_to(machine, 'ip')}
		</td>
		<td>
			${machine_comps.link_to(machine, 'macaddress')}
		</td>
		<td>
			${student_comps.link_to(machine.user)}
		</td>
	</tr>
%endfor
</table>